<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>发货单管理</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active">
		
			<c:choose>
				<c:when test="${shopOrder.status == '1'}"><a href="#">待发货</a></c:when>
				<c:otherwise>
					<a href="${ctx}/shop/order/manage/">发货单列表</a>
				</c:otherwise>
			</c:choose>
		</li>
	</ul>
	<form:form id="searchForm" modelAttribute="shopDispatch"
		action="${ctx}/shop/dispatch/" method="post"
		class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}" />
		<ul class="ul-form">
			<li><label>订单编号：</label> <form:input path="orderId"
					htmlEscape="false" maxlength="64" class="input-medium" /></li>
			<li><label>收货人：</label> <form:input path="name"
                  htmlEscape="false" maxlength="64" class="input-medium" /></li>
			<%-- <li><label>创建时间：</label> <input name="createTime" type="text"
				readonly="readonly" maxlength="20" class="input-medium Wdate"
				value="<fmt:formatDate value="${shopDispatch.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
				onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" />
			</li> --%>
			<li><label>发货单状态：</label> 
			    <form:select path="status" htmlEscape="false" maxlength="4" class="input-medium" >
                    <form:option value="">请选择</form:option>
                    <form:option value="1">待发货</form:option>
                    <form:option value="2">已发货</form:option>
                    <form:option value="3">已收货</form:option>
                </form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary"
				type="submit" value="查询" /></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}" />
	<table id="contentTable"
		class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>订单编号</th>
				<th>下单时间</th>
				<th>收货人</th>
				<th>联系电话</th>
				<th>所选物流</th>
				<th>物流费用</th>
				<th>支付时间</th>
				<th>订单总价</th>
				<th>发货状态</th>
				<th>备注</th>
				<shiro:hasPermission name="shop:dispatch:manage:edit">
					<th>操作</th>
				</shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="shopDispatch">
				<tr>
					<td><a
						href="${ctx}/shop/dispatch/form?id=${shopDispatch.id}">
							${shopDispatch.shopOrder.code} </a></td>
				   <td><fmt:formatDate value="${shopDispatch.shopOrder.createTime}"
                            pattern="yyyy-MM-dd" /></td>
					<td>${shopDispatch.name}</td>
					<td>${shopDispatch.telephone}</td>
					<td>
						<c:forEach items="${logisticsCodes }" var="logisticsCode">
							<c:if test="${shopDispatch.company eq logisticsCode.logisticsCode}">
							     ${logisticsCode.logisticsCompany}
							</c:if>
						</c:forEach> 
					</td>
					<td>${shopDispatch.shopOrder.freight}</td>
					<td><fmt:formatDate value="${shopDispatch.shopOrder.payTime}" pattern="yyyy-MM-dd hh:mm:ss"/></td>
					<td>${shopDispatch.shopOrder.totalAmount}</td>
					<td><c:choose>
							<c:when test="${shopDispatch.status == '1'}">待发货</c:when>
							<c:when test="${shopDispatch.status == '2'}">已发货</c:when>
							<c:when test="${shopDispatch.status == '3'}">已收货</c:when>
						</c:choose></td>
					
					<td>${shopDispatch.comment}</td>
					<shiro:hasPermission name="shop:dispatch:manage:edit">
						<td><a
							href="${ctx}/shop/dispatch/form?id=${shopDispatch.id}">去发货</a>
							<a href="${ctx}/shop/dispatch/print?id=${shopDispatch.id}"">配货单</a></td>
					</shiro:hasPermission>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>